﻿<#

.SYNOPSIS
Deletes lists by Created Date.

.DESCRIPTION
Deletes all lists in the web provided on the date provided.

.EXAMPLE
Delete-ListsByCreated -CreatedDate "2/20/2013" -WebPath "http://dev.contoso.com"

.LINK
http://usefulPOSHCmdlets.codeplex.com

#>
Function Delete-ListsByCreated (
		[Parameter(Mandatory=$True, Position=0)]
        	[string]$CreatedDate, 
        
        	[Parameter(Mandatory=$True, Position=1)]
        	[string]$WebPath
	) 
{
		$web = Get-SPWeb $WebPath
		$global:numDel = 0

		$lists = $web.Lists

		for($index = 0; $index -lt $lists.Count; $index++){
			Write-Host $index "-" $lists[$index].Title
	
			if($lists[$index].Created.ToString().StartsWith($CreatedDate)){
				Write-Host "	Deleted"
				$lists[$index].Delete()
				$global:numDel++
				$index--
			}
		}

		if($web){$web.Dispose()}

		Write-Host "Total Deleted:" $global:numDel
}

<#

.SYNOPSIS
Deletes Site Columns by Internal Name Prefix.

.DESCRIPTION
Deletes all Site Columns in the web provided with the Prefix provided.

.EXAMPLE
Delete-ColumnsByInternalPrefix -InternalNamePrefix "SPSAustin_" -WebPath "http://dev.contoso.com"

.LINK
http://usefulPOSHCmdlets.codeplex.com

#>
Function Delete-ColumnsByInternalPrefix (
		[Parameter(Mandatory=$True, Position=0)]
		[string]$WebPath,

		[Parameter(Mandatory=$True, Position=1)]
		[string]$InternalNamePrefix
	)
{
$web = Get-SPWeb $WebPath
$global:numDel = 0
for($i=0; $i -lt $web.Fields.Count; $i++){
	$web.Fields[$i].InternalName
	if($web.Fields[$i].InternalName.StartsWith($InternalNamePrefix)){
		$web.Fields[$i].Delete()
		Write-Host "     Deleted"
		$i--
		$global:numDel++
	}
}

Write-Host "Total Deleted: $numDel"
if($web){$web.Dispose()}
}

